package com.jd.controller;

import java.util.ArrayList;
import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jd.entity.MatchEntity;
import com.jd.service.MatchService;
/**
 * @author masicheng 
 * 时间 : 2020年12月16日 下午2:25:47 
 * 注释 :比赛
 */
@Controller
@RequestMapping("matchController")
public class MatchController {

	@Autowired
	private MatchService matchService;
	//最近两场比赛
	@RequestMapping("getTwoMatch")
	@ResponseBody
	public ArrayList<HashMap<String, Object>> getTwoMatch(HttpServletRequest request){
		String code = request.getParameter("code");
		ArrayList<HashMap<String, Object>> matchList=matchService.getTwoMatch(code);
		return matchList;
	}
	//比赛列表
	@RequestMapping("getMatchList")
	@ResponseBody
	public ArrayList<HashMap<String, Object>> getMatchList(HttpServletRequest request){
		String nameId = request.getParameter("nameId");
		String fn = request.getParameter("fn");
		HashMap<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("nameId", nameId);
		hashMap.put("fn", fn);
		ArrayList<HashMap<String, Object>> matchList=matchService.getMatchList(hashMap);
		return matchList;
	}
	
	//比赛详情
	@RequestMapping("getMatchContent")
	@ResponseBody
	public HashMap<String, Object> getMatchContent(HttpServletRequest request){
		String id = request.getParameter("id");
		String userId = request.getSession().getAttribute("userId").toString();
		HashMap<String, Object> match=matchService.getMatchContent(id,userId);
		return match;
	}
	//我的比赛
	@RequestMapping("myMatch")
	@ResponseBody
	public ArrayList<HashMap<String, Object>> myMatch(HttpServletRequest request){
		String userId = request.getSession().getAttribute("userId").toString();
		String start = request.getParameter("start");
		String fn = request.getParameter("fn");
		HashMap<String, String> map = new HashMap<String,String>();
		map.put("userId", userId);
		map.put("start", start);
		map.put("fn", fn);
		ArrayList<HashMap<String, Object>> match=matchService.myMatch(map);
		return match;
	}
}
